<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Register/注册</title>
  <style>
    body {
      font-family: 'Arial', sans-serif;
      background-image: url('/images/2.png'); /* 设置背景图片 */
      background-size: cover; /* 覆盖整个页面 */
      background-position: center; /* 居中显示 */
      margin: 0;
      padding: 20px;
      display: flex;
      justify-content: center;
      align-items: center;
      min-height: 100vh;
    }

    h1, h2 {
      text-align: center;
      color: #333;
    }

    h1 {
      font-size: 2.5em;
      margin-bottom: 0;
    }

    h2 {
      font-size: 1.5em;
      margin-top: 0;
    }

    .container {
      max-width: 400px;
      width: 100%;
      background: rgba(255, 255, 255, 0.3); /* 半透明背景以增强可读性 */
      padding: 20px;
      border-radius: 10px;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
      display: flex;
      flex-direction: column;
      align-items: center;
    }

    label {
      font-weight: bold;
      margin-top: 20px;
    }

    input[type="text"], input[type="password"] {
      width: calc(100% - 20px);
      padding: 10px;
      margin-top: 5px;
      border: 1px solid #ccc;
      border-radius: 5px;
      box-sizing: border-box;
      font-size: 16px;
    }

    button {
      background-color: #5cb85c;
      color: white;
      border: none;
      padding: 10px 15px;
      border-radius: 5px;
      cursor: pointer;
      font-size: 16px;
      margin-top: 15px;
      width: 100%;
      transition: background-color 0.3s;
    }

    button:hover {
      background-color: #4cae4c;
    }

    .sign-up-link {
      margin-top: 10px;
      font-size: 14px;
      color: #5cb85c;
      text-align: center;
      display: block;
    }

    .sign-up-link:hover {
      text-decoration: underline;
    }
    .error-message {
      color: red;
      margin-top: 10px;
    }
  </style>
</head>
<body>
<div class="container">
  <h2>注册</h2>
  <form th:object="${user}" th:action="@{/prt/register}" method="post">
    <label>Username/用户名:</label>
    <input type="text" th:field="*{username}" />

    <label>Password/密码:</label>
    <input type="password" th:field="*{password}" />

    <button type="submit">注册</button>
    <!-- 显示错误消息 -->
    <div th:if="${error}" class="error-message">
      <span th:text="${error}"></span>
    </div>
  </form>
  <div class="sign-up-link">
    <a th:href="@{/prt/login}">已有账号？去登录</a>
    <!--        <a th:href="@{/blogs/list}">Back to Blog List</a>-->
  </div>
</div>
</body>
</html>